<template>
  <div class="base-table-box">
    <div class="table-select-group" v-if="!isAdvanced">
      <div class="left">
        <a-select default-value="">
          <a-select-option value="">=是否公开= </a-select-option>
          <a-select-option value="0"> 是 </a-select-option>
          <a-select-option value="1"> 否 </a-select-option>
        </a-select>
        <s-select
          :selectOption="year"
          v-model="params.strYear"
          style="width: 100px"
        />
        <a-select default-value="" style="width: 120px">
          <a-select-option value="">=批示情况= </a-select-option>
          <a-select-option value="0"> 已批示 </a-select-option>
          <a-select-option value="1"> 未批示 </a-select-option>
        </a-select>
        <a-select default-value="" style="width: 100px">
          <a-select-option value="">全部</a-select-option>
          <a-select-option value="0"> 刊物标题 </a-select-option>
          <a-select-option value="1"> 刊物来源 </a-select-option>
          <a-select-option value="1"> 刊物内容</a-select-option>
        </a-select>
        <a-input
          class="search-input"
          v-model="params.search"
          placeholder="请输入搜索内容"
        />
        <a-button style="margin-left: 16px" type="primary" @click="start"
          >查询</a-button
        >
        <a-button @click="reset" class="btn-reset">重置</a-button>
      </div>
      <div class="upper-right">
        <div class="btn-group">
          <a-button type="primary" class="btn" @click="addPublication"
            >新增</a-button
          >
          <a-button type="danger">删除</a-button>
          <menu-button
            @menuClick="handleMenuClick"
            :menus="[{ key: 'export', label: '导出刊物' }]"
          ></menu-button>
        </div>
      </div>
      <div class="publicationList">
        <span style="cursor: default" class="publication-btn"
          >社情民意:1期</span
        >
      </div>
    </div>
    <a-table
      :pagination="pagination"
      :columns="columns"
      :data-source="tableData"
      :loading="loading"
      :scroll="{ y: '100%' }"
    >
      <div slot="action">
        <div class="tools">
          <span @click="instruction">批示</span>
          <span>编辑</span>
          <span>删除</span>
        </div>
      </div>
      <div slot="state" slot-scope="text">
        {{ text }}
      </div>
      <template slot-scope="text, record, index" slot="listIndex">
        <span>{{ index + 1 }}</span>
      </template>
    </a-table>
    <!-- 批示弹框 -->
    <publicationInstruction
      :instructionVisible="instructionVisible"
      @closeFunc="instructionVisible = false"
    ></publicationInstruction>
  </div>
</template>
<script>
import MenuButton from 'components/base/menuButton.vue'
import paging from 'mixins/paging'
import deleteItem from 'mixins/delete-table-item.js'
import { socialPublic } from 'assets/js/select-option-list'
import publicationInstruction from './publicationInstruction'
const columns = [
  {
    title: '序号',
    scopedSlots: { customRender: 'listIndex' }
  },
  {
    title: '信息标题',
    dataIndex: 'title'
  },
  {
    title: '上报人',
    dataIndex: 'person'
  },
  {
    title: '上报类型',
    dataIndex: 'type',
    scopedSlots: { customRender: 'state' }
  },
  {
    title: '提交时间',
    dataIndex: 'time',
    sorter: (a, b) => a.name.length - b.name.length
  },
  {
    title: '主题类型',
    dataIndex: 'themetype'
  },
  {
    title: '状态',
    dataIndex: 'state'
  },
  {
    title: '是否采编',
    dataIndex: 'isAccept'
  },
  {
    title: '操作',
    scopedSlots: { customRender: 'action' }
  }
]

export default {
  data() {
    return {
      instructionVisible: false,
      topicTypeVal: '',
      treeData: [
        {
          title: '=主题类型=',
          value: '',
          key: '1'
        },
        {
          title: '文化建设',
          value: '文化建设',
          key: '2',
          children: [
            {
              value: '街道文化建设',
              key: '2-1',
              title: '街道文化建设'
            }
          ]
        },
        {
          title: '经济建设',
          value: '经济建设',
          key: '3'
        },
        {
          title: '政协建设',
          value: '政协建设',
          key: '4'
        }
      ],
      isAdvanced: false,
      isJointname: 1, //是否联名
      columns,
      socialPublic,
      params: {
        strYear: '2021',
        strPubType: 'all',
        strPubNode: 'all',
        search: ''
      },
      year: [
        { key: '2021', label: '2021' },
        { key: '2020', label: '2020' }
      ],
      labelCol: { span: 6 },
      wrapperCol: { span: 18 }
    }
  },
  mixins: [paging, deleteItem],
  components: { MenuButton, publicationInstruction },
  methods: {
    instruction() {
      //批示
      this.instructionVisible = true
    },
    handleMenuClick() {},
    toggle() {
      this.isAdvanced = !this.isAdvanced
    },
    start() {
      console.log(this.form)
    },
    reset() {
      this.form = {}
    },
    addPublication() {
      this.$router.push(
        '/console/socialPublic/publication/publicationList/publicationListAdd'
      )
    },
    deleteList(ids) {
      this.deleteItemMixins(() => {}, ids)
    },
    getTableData() {
      for (let i = 0; i < this.pagination.pageSize; i++) {
        this.tableData.push({
          key: i,
          title: `Edward King ${i}`,
          person: '张三',
          time: `20210303`,
          type: '经济建设',
          isAccept: '已采编',
          state: '通过',
          themetype: '测试'
        })
      }
      this.pagination.total = 200
    }
  }
}
</script>
<style lang="less" scoped>
.tools span {
  margin: 0 0 0 15px;
}
.tools span {
  color: #1c8de8;
  cursor: pointer;
  font-size: 16px;
}
.end {
  color: green;
}
.start {
  color: red;
}
.advanced-name {
  line-height: 34px;
  margin-bottom: 5px;
  font-size: 16px;
  color: #000000;
  font-weight: bold;
  span {
    height: 20px;
    line-height: 20px;
    /* border-left: 5px solid #0b78e7; */
    padding: 0px 10px;
    display: inline-block;
    vertical-align: middle;
    margin-top: -3px;
    margin-right: 5px;
  }
}
.advanced-search-group {
  padding: 15px 10px 5px 15px;
}
.search-btn {
  text-align: center;
  margin-top: 10px;
}
.advanced-search-group {
  padding-bottom: 40px;
  position: relative;
  background: #fff;
}
.search-switch {
  width: 36px;
  height: 36px;
  position: absolute;
  bottom: -10px;
  left: 50%;
  text-align: center;
  cursor: pointer;
  background: #ffffff;
  border-radius: 50%;
  margin-left: -18px;
  i {
    color: #4297ee;
    font-size: 20px;
    margin-top: 10px;
    display: inline-block;
    animation: arrow 0.7s linear infinite normal;
  }
}
@keyframes arrow {
  from {
    margin-top: 10px;
  }
  to {
    margin-top: 5px;
    opacity: 0;
  }
}
.ant-form-inline .ant-form-item {
  width: 100%;
}
.upper-right {
  float: right;
}
/**按钮重置样式 */
.btn-group {
  display: flex;

  /**扩展按钮重置样式 */
  /deep/.dropdown-btn {
    height: 34px;
    border: 1px solid #d9d9d9;
    background-color: #fff;
    &:hover {
      background-color: #fff;
      border-color: #1c8de8;
      color: #1c8de8;
    }
  }
}
.publication-btn {
  border: 1px solid #c9c9c9;
  background-color: #fff;
  color: #555;
  display: inline-block;
  vertical-align: middle;
  height: 34px;
  line-height: 34px;
  padding: 0 18px;
  white-space: nowrap;
  text-align: center;
  font-size: 14px;
  border-radius: 4px;
}
.publication-btn:hover {
  border: 1px solid #1075c6;
  color: #1075c6;
  background: none;
}
.publicationList {
  clear: both;
  padding-top: 15px;
}
</style>